<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<meta name="keywords" content="">
		<meta name="description" content="">
		<title>登录界面</title>
		<link href="common-1.css" tppabs="http://www.xunron.cn/cases/hmshop/css/common.css" rel="stylesheet" />
		<link href="login-1.css" tppabs="http://www.xunron.cn/cases/hmshop/css/login.css" rel="stylesheet"  />
		<!--<script src="js/jquery-1.12.4.min.js"></script>-->
		<script  src="jquery-1.12.4.min.js" tppabs="http://code.jquery.com/jquery-1.12.4.min.js"></script>
	</head>
	<body>
		<header>
			<div id="head">
				<div class="logo">
					<a href="index.php.htm" tppabs="http://www.xunron.cn/cases/hmshop/index.php"><img src="logo-1.png" tppabs="http://www.xunron.cn/cases/hmshop/images/logo.png" /></a>
					<span>数码在线网上商城</span>
				</div>
				<div class="reg_text">
					<span>还没有商城账号？<a href="register.php.htm" tppabs="http://www.xunron.cn/cases/hmshop/register.php">立即注册</a></span>
				</div>
			</div>
		</header>
		<section>
			<div class="login_ad">
				<img src="login_bg-1.jpg" tppabs="http://www.xunron.cn/cases/hmshop/images/login_bg.jpg" />

			</div>
			<div class="login_box">
				<p class="login_head">
					<span class="title">登录商城</span><span class="mob"><a href="javascript:;">手机动态登录</a></span>
				</p>
				<form action="" id="loginForm" method="post">
					<div><input type="text" name="userName" placeholder="手机号/邮箱/用户名" autofocus /><span id='loginMsg'></span></div>
					<div><input type="password" name="userPwd" placeholder="密码" /></div>
					<div>
						<label><input type="checkbox" id="accept" checked />7天免登录</label>
						<a href="javascripta:;" class="forget">忘记密码？</a>
						<div class="clear"></div>
					</div>
					<div><input type="button" id="btnLogin" class="img_submit" value="登录" /></div>
				</form>
				<div class="fast_login">
					<span>合作账号：</span>
					<a href="javascript:;" class="weibo"></a>
					<a href="javascript:;" class="qq"></a>
					<a href="javascript:;" class="pay"></a>
					<a href="javascript:;" class="baidu"></a>
				</div>
			</div>
		</section>
		<footer>
			<div id="foot">
				<span class="foot_link">
					<a href="javascript:;">关于HM商城</a> |
					<a href="javascript:;">联系我们</a> |
					<a href="javascript:;">帮助中心</a>
				</span>
				<span class="foot_copyscript">©2016. HM商城 版权所有</span>
			</div>
		</footer>
		<script>
			btnLogin.onclick=function(){
				var userName=loginForm.userName.value;
				var userPwd=loginForm.userPwd.value;
				if(userName.trim()==""){
					alert('用户名不能为空!')
					loginForm.userName.focus();
					return;
				}
				if(userPwd.trim()==""){
					alert('密码不能为空!')
					loginForm.userPwd.focus();
					return;
				}
				var xhr=new XMLHttpRequest();
				xhr.onreadystatechange=function(){
					if(xhr.readyState==4&&xhr.status==200){
						if(xhr.responseText=='pass'){
							alert('登录成功！')
							if(accept.checked){
								var now=new Date();
								now.setDate(now.getDate()+7);
								document.cookie='userName='+userName+';expire='+now.toGMTString();
								document.cookie='userPwd='+userPwd+';expire='+now.toGMTString();
							}
							//window.sessionStorage.setItem('userName',userName);
							//window.sessionStorage.setItem('userPwd',userPwd);
							location.href="index.php.htm"/*tpa=http://www.xunron.cn/cases/hmshop/index.php*/;
						}else if(xhr.responseText=='err'){
							loginMsg.innerHTML="用户名或者密码错误";
						}
					}
				}
				var url='admin/login_fail.php?ename='+userName+'&pwd='+userPwd;
				xhr.open('GET',url,true);
				xhr.send(null);
			}
		</script>
	</body>
</html>
